package com.qf.dao.impl;

import com.qf.dao.OrderItemDao;
import com.qf.pojo.OrderItem;
import com.qf.utils.DBTools;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

public class OrderItemDaoImpl implements OrderItemDao {

    QueryRunner qr=new QueryRunner(DBTools.getDataSource());

    @Override
    public int insert(OrderItem item) {
        String sql="INSERT INTO orderitem VALUES (null,?,?,?,?,?,?)";
        try {
            return qr.update(DBTools.getConnection(),sql,item.getGid(),item.getOid(),item.getPic(),
                    item.getPrice(),item.getGnum(),item.getGname());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
